<script setup>
import {ref,reactive} from 'vue'

const st = reactive({})

const name = ref('')
// const result = ref('')
//
// function show() {
//   if (result.value === '') {
//     result.value += name.value
//   } else {
//     result.value += ','
//     result.value += name.value
//   }
// }

const show = () => {
  result.value.push(name.value)
  name.value = ''
}

const result = ref([])
</script>

<template>
  <label><input @keyup.enter="show" type="text" v-model="name">{{name}}</label>
  <button @click="show">search1</button>
  <button @click="result.push(name)">search2</button>
  <button @click="result.splice(0,result.length)">clear all search</button>
  <div>
    搜索：{{ result.join(',') }}
  </div>
</template>
